package com.vinjogames.som.entities;

import javax.microedition.khronos.opengles.GL10;

import android.graphics.PointF;

import com.vinjogames.gfx.Image;
import com.vinjogames.gfx.TextureId;
import com.vinjogames.util.GameClock;

public class Tile {
	
	public static final int WIDTH  = 1;
	public static final int HEIGHT = 1;
	
	private int mType;
	private Image mImage;
	private int mapX;
	private int mapY;
	
	PointF originPoint;//temp
	
	public Tile(int type, int mapX, int mapY){
		originPoint = new PointF(0,0);
		
		this.mType = type;
		this.mapX = mapX;
		this.mapY = mapY;
		
		this.mImage = new Image(type, WIDTH,HEIGHT);
		
		if(type == TextureId.WATER_TEXTURE_ID){
			this.mImage.setAnimations(new int[]{0,3,0});
		}
		//TODO:  init image based on type?? make it easy by making type texture id?
	}
	
	public void draw(GL10 gl){
		draw(gl, this.mapX, this.mapY);
	}
	
	public void draw(GL10 gl, int mapX, int mapY){
		gl.glPushMatrix();
		gl.glTranslatef(mapX, mapY, 0);	
		gl.glTranslatef(0.5f, 0.5f, 0);
		mImage.draw(gl, originPoint, GameClock.getInstance().getTime());
		//Font.drawString(gl, mapX + ":" + mapY, 0.3f);
		gl.glPopMatrix();
	}
	
	public int getType(){ return mType; }
	public int getX()   { return mapX; }
	public int getY()   { return mapY; }
}
